package com.gitee.xhs.sourceIterator.skipFunction;

import cn.hutool.core.date.DateUtil;
import com.gitee.xhs.sampleRecod.transactionRecord.Transaction;
import com.gitee.xhs.sourceIterator.CheckSkipInterface;

/**
 * @author BigHead
 * @date 2022/7/25 17:28
 * @description TransactionTimerSkiper
 */
public class TransactionSecondTimerSkipper implements CheckSkipInterface<Transaction> {

    private final static Integer SECOND_SKIP = 10;
    private final int SKIP_LOOP_KEY;

    public TransactionSecondTimerSkipper(Integer skipLoopKey){
        this.SKIP_LOOP_KEY = skipLoopKey;
    }

    @Override
    public Boolean checkSkip(Transaction object) {
        Long transactionAccountId = object.getAccountId();
        Long remainder = (long) DateUtil.date(object.getTimestamp()).second() / SECOND_SKIP % SKIP_LOOP_KEY;
        return transactionAccountId.equals(remainder);
    }


}
